package czy.demo.controller;

import czy.demo.pojo.system.User;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/* 首页控制器 */
@Controller
public class IndexController {

    /* 首页控制器，需要登录后才能访问，平时访问使用GET方法，但是security登出成功后请求转发时使用POST方法 */
    @RequestMapping(value = "index",method = {RequestMethod.GET,RequestMethod.POST})
    @PreAuthorize("authenticated")
    public String index(@AuthenticationPrincipal User user, Model model){
        return "index";
    }

}
